package com.ftg.mall.service.impl;

import com.ftg.mall.base.entity.pms.ProductCategory;
import com.ftg.mall.base.util.tools.ConvertUtil;
import com.ftg.mall.base.util.tooltips.ResBean;
import com.ftg.mall.mapper.ProductCategoryMapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ftg.mall.service.IProductCategoryService;
import com.ftg.mall.vo.ProductCategoryVo;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 产品分类 服务实现类
 * </p>
 *
 * @author kangjx
 * @since 2022-11-15
 */
@Service
public class ProductCategoryServiceImpl extends ServiceImpl<ProductCategoryMapper, ProductCategory> implements IProductCategoryService {

    @Override
    public ResBean showTreeWithCategory() {
        //数据库表里面的全部数据
        List<ProductCategory> list = this.baseMapper.selectList(null);
        //转换成为一个树
        List<ProductCategoryVo> tree = ConvertUtil.convertClass(list,ProductCategoryVo.class);
        //通过老程序  200优化成为了一行
        return ResBean.success(tree);
//        return ResBean.success(ConvertUtil.convertClass(this.baseMapper.selectList(null),ProductCategoryVo.class));
    }

}
